OpenBuildings GenerativeComponents Help

Nodes() and SelectNodes()

Nodes()

The library function Nodes returns a list of all of the nodes in the OpenBuildingsā„¢ GenerativeComponents model, or only those nodes that fulfill a given criteria.

Node[] Nodes(function selector=null)

Following are examples of use.

Get all nodes:

Nodes()

Get all Line nodes:

Nodes(n => n is Line)

Get all nodes whose names start with "bspline":

Nodes(n => n.Name.StartsWith('bspline'))

Get all Polygon nodes that have less than five vertices:

Nodes(n => n is Polygon && n.Vertices.Count < 5)

Get all red-colored Line nodes whose length is greater than the height of point01:

Nodes(n => n is Line && n.Color == Colors.Red && n.Length > point01.Z)

SelectNodes()

The library function SelectNodes is a variant of Nodes. Aside from returning all of the nodes, SelectNodes can return the replicated children of those nodes, based on a given maximum replication depth.

Node[] SelectNodes(int maximumReplicationDepth, function selector=null)

We choose a value for maximumReplicationDepth that is relevant to the results we want:

  • 0 - All nodes, regardless of their replication levels. (Same as returned by the Nodes function.)
  • 1 - Non-replicated nodes, plus the immediate children of replicated nodes.
  • 2 - Non-replicated nodes, plus the children of nodes having exactly one level of replication, plus the second-level children of nodes having at least two levels of replication.
  • 3 - Non-replicated nodes, plus the children of nodes having exactly one level of replication, plus the second-level children of nodes having exactly two levels of replication, plus the third-level children of nodes having at least three levels of replication.
  • And so on...

As with the Nodes function, we can provide an additional "selector" function that limits the results to only those nodes that fulfill a given criteria.

Following are examples of use.

Get all top-level nodes (the same as calling Nodes()):

SelectNodes(0)

Get all Line nodes (the same as calling Nodes(n => n is Line)):

SelectNodes(0, n => n is Line)

Get all non-replicated nodes, plus the immediate children of all replicated nodes.

SelectNodes(1)

Get all non-replicated Line nodes, plus the immediate children of all replicated Line nodes.

SelectNodes(1, n => n is Line)